package com.vend.common.permission;
import android.content.Context;
import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.XXPermissions;
import java.util.List;
/**
 * Created by glendal on 2022/01/14.
 * 对XXpermission进行封装
 */
public class VPermission {
    /**
     * 多个的情况
     * @param context 上下文
     * @param listener 监听
     * @param permissions 请求组
     */
    public static void requesterPermission(Context context, RequestPermissionListener listener, String[]... permissions){
        XXPermissions.with(context) // 适配 Android 11 分区存储这样写
                .permission(permissions)
                .request(new OnPermissionCallback(){

                    @Override
                    public void onGranted(List<String> permissions, boolean all) {
                        listener.onGranted(permissions,all);
                    }

                    @Override
                    public void onDenied(List<String> permissions, boolean never) {
                        listener.onDenied(permissions,never);
                    }
                });

    }

    /**
     * 单个的请求
     * @param context 上下文
     * @param listener 监听
     * @param permissions 请求string average
     */
    public static void requesterPermission(Context context, RequestPermissionListener listener, String... permissions){
        XXPermissions.with(context) // 适配 Android 11 分区存储这样写
                .permission(permissions)
                .request(new OnPermissionCallback(){

                    @Override
                    public void onGranted(List<String> permissions, boolean all) {
                        listener.onGranted(permissions,all);
                    }

                    @Override
                    public void onDenied(List<String> permissions, boolean never) {
                        listener.onDenied(permissions,never);
                    }
                });

    }
}
